import React, { Component } from 'react'
import { address } from '../api/index'
import {EditSOutline } from 'antd-mobile-icons'
export default class Address extends Component {

    componentDidMount() {
        this.getlist()
    }

    getlist = () => {
        address().then(res => {
            this.setState({
                address: res.data.data,
            })
        })
    }

    state = {
        address: []
    }


    render() {
        const { address } = this.state;
        return (
            <div className="address">

                <div className="address_header">
                    <p onClick={() => { this.props.history.goBack() }}>&lt;&nbsp;返回</p>
                    <p>收货地址</p>
                    <p></p>
                </div>

                <div className="address_main">
                    {
                        address ? address.map((item, index) => {
                            return <dl key={index}>
                                <dd>
                                    <p><span>{item.name}</span><span>{item.number}</span></p>
                                    <p>{item.addresss}</p>
                                </dd>
                                <dd>
                                <EditSOutline />
                               </dd>
                            </dl>
                        }) : null
                    }
                </div>
                <div className="address_footer">
                    <button onClick={() => { this.order() }}>新建地址</button>
                </div>
            </div>
        )
    }
}
